package com.project.nimsen.web.sys;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.project.jdbc.web.BaseMVCAction;
import com.project.nimsen.dto.MenuDto;
import com.project.nimsen.service.ISMenuService;
/**
 * 菜单Control
 * */
@Controller
@RequestMapping(value ="/sys/menu")
public class MenuControl extends BaseMVCAction {
	@Resource
	ISMenuService menuService;
	/**
	 * 主界面左则菜单
	 * @return
	 */
	@RequestMapping(value ="/leftTree")
	@ResponseBody
	public List<Map<String,Object>> leftTree(){
		MenuDto dto = new MenuDto();
		String pcode = getParameter("code");
		if(StringUtils.isBlank(pcode)){
			dto.setPcode("0");
		}else{
			dto.setPcode(pcode);
		}
		try {
			List<Map<String, Object>> menus = menuService.findByDto(dto);
			if(CollectionUtils.isEmpty(menus))
				return null;
			return menus;
		} catch (Exception e) {
			logger.error(e);
			e.printStackTrace();
		}
		return null;
	}
}